/// @tags: HigherDimensionPresum
#include <cstdio>
#include <iostream>
#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

constexpr int maxn = 19;

struct Node {
  int f, s;
} a[1 << maxn];

inline int main() {
  int n;
  cin >> n;
  for (int i = 0, ilim = 1 << n; i < ilim; ++i) cin >> a[i].f;
  for (int j = 0; j < n; ++j)
    for (int i = 0, ilim = 1 << n; i < ilim; ++i)
      if (i >> j & 1) {
        int x = i ^ (1 << j);
        Node ans;
        ans.f = std::max(a[i].f, a[x].f);
        if (a[i].f > a[x].f)
          ans.s = std::max(a[i].s, a[x].f);
        else
          ans.s = std::max(a[i].f, a[x].s);
        a[i] = ans;
      }
  int ans = 0;
  for (int i = 1, ilim = 1 << n; i < ilim; ++i) {
    ans = std::max(ans, a[i].f + a[i].s);
    cout << ans << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("AT4168 [ARC100C] Or Plus Max.in", "r", stdin);
  freopen("AT4168 [ARC100C] Or Plus Max.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
